﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MouseExtender.Interfaces;
using MouseExtender.Plugins.Item;

namespace MouseExtender.View
{
    /// <summary>
    /// Interaction logic for EditItemView.xaml
    /// </summary>
    public partial class EditItemView : UserControl
    {
        private IItemEditor _specializedEditor = null;
        private IItem _item = null;
        public EditItemView(UserControl specializedEditor, IItem item)
        {
            _specializedEditor = (IItemEditor)specializedEditor;
            _item = item;
            InitializeComponent();
            DataContext = _item;
            //            GlobalServices.ModalService.GoBackward(true);
            CustomEditor.Content = specializedEditor;
        }

        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            _specializedEditor.SaveChanges(_item);
            GlobalServices.ModalService.GoBackward(true);
        }
        private void ButtonCancel_Click(object sender, RoutedEventArgs e)
        {
            _specializedEditor.CancelChanges(_item);
            GlobalServices.ModalService.GoBackward(false);
        }
    }
}
